package com.zzty.txj1.controller;

import com.zzty.txj1.entity.RestaurantPoint;
import com.zzty.txj1.service.RestaurantPointService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/restaurantPoint")
public class RestaurantPointController {
    private static final Logger logger = LoggerFactory.getLogger(RestaurantPointController.class);

    @Autowired
    private RestaurantPointService restaurantPointService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map add(RestaurantPoint restaurantPoint) {
        logger.info("restaurantPoint--controller ============ add");

        Map<String, String> result = new HashMap<>();
        String resultValue = "false";
        Integer count = restaurantPointService.addRestaurantpoint(restaurantPoint);
        if (count == 1) {
            resultValue = "success";
        }
        result.put("msg", resultValue);
        return result;
    }

    @RequestMapping("getAll")
    public List getAll() {
        logger.info("restaurantPoint--controller ============ getAll");

        List<RestaurantPoint> restaurantPoints = restaurantPointService.getAllRestaurantpoint();
        return restaurantPoints;
    }
}
